package kr.hkit.powerjava.alone;

import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JButton;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class button extends JPanel implements ActionListener {
	private JButton button;

	/**
	 * Create the panel.
	 */
	public button() {

		initialize();
	}
	private void initialize() {
		
		button = new JButton("변환");
		button.addActionListener(this);
		add(button);
	}

	public void actionPerformed(ActionEvent e) {
		buttonFram bf = new buttonFram();
		if (e.getActionCommand().equals("변환")) {
			int mile = 0;
			try {
				mile = Integer.parseInt(bf.getPanel_1().getTextField().trim());
			} catch (NumberFormatException err) {
				JOptionPane.showMessageDialog(this, "숫자만 가능");
				bf.getPanel_1().setTextField("");
				
			}
			bf.getPanel_2().setTextField(mile + " 마일은 " + (mile * 1.6) + " 킬로미터입니다.");

		
		}
	}
}
